import { createRouter, createWebHistory } from 'vue-router'
import HomePage from '../pages/HomePage.vue'
import LoginUserPage from '@/pages/user/LoginUserPage.vue'
import RegisterUserPage from '@/pages/user/RegisterUserPage.vue'
import ManageUserPage from '@/pages/user/ManageUserPage.vue'
import accessEnum from '@/access/accessEnum.ts'
import { HomeOutlined, UsergroupAddOutlined, FileImageOutlined,FireOutlined } from '@ant-design/icons-vue'
import { h } from 'vue'
import AddImagePage from '@/pages/image/AddImagePage.vue'
import ManageImagePage from '@/pages/image/ManageImagePage.vue'
import ImageDetailPage from '@/pages/image/ImageDetailPage.vue'
import AddImageBatchPage from '@/pages/image/AddImageBatchPage.vue'
import ManageSpacePage from '@/pages/space/ManageSpacePage.vue'
import AddSpacePage from '@/pages/space/AddSpacePage.vue'
import MySpacePage from '@/pages/space/MySpacePage.vue'
import SpaceDetailPage from '@/pages/space/SpaceDetailPage.vue'
import ImageSearchPage from '@/pages/image/ImageSearchPage.vue'
import AnalyzeStatistics from '@/components/AnalyzeStatistics.vue'
import ManageSpaceUserPage from '@/pages/spaceUser/ManageSpaceUserPage.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: '主页',
      component: HomePage,
      meta: {
        icon: () => h(FireOutlined),
      },
    },
    {
      path: '/user/login',
      name: '用户登录',
      component: LoginUserPage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/user/register',
      name: '用户注册',
      component: RegisterUserPage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/image/add',
      name: '新增图片',
      component: AddImagePage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/image/add/batch',
      name: '批量创建图片',
      component: AddImageBatchPage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/image/detail/:id',
      name: '图片详情',
      component: ImageDetailPage,
      props: true,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/image/search',
      name: '图片搜索',
      component: ImageSearchPage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/analyze',
      name: '分析',
      component: AnalyzeStatistics,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/spaceUserManage/:id',
      name: '空间成员管理',
      component: ManageSpaceUserPage,
      props: true,
      meta: {
        hideInMenu: true,
      },
    },

    {
      path: '/space/detail/:id',
      name: '空间详情',
      component: SpaceDetailPage,
      props: true,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/my_space',
      name: '我的空间',
      component: MySpacePage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/space/add',
      name: '创建空间',
      component: AddSpacePage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/admin/spaceManage',
      name: '空间管理',
      component: ManageSpacePage,
      meta: {
        access: accessEnum.ADMIN,
        icon: () => h(HomeOutlined),
      },
    },
    {
      path: '/admin/imageManage',
      name: '图片管理',
      component: ManageImagePage,
      meta: {
        access: accessEnum.ADMIN,
        icon: () => h(FileImageOutlined),
      },
    },
    {
      path: '/admin/userManage',
      name: '用户管理',
      component: ManageUserPage,
      meta: {
        access: accessEnum.ADMIN,
        icon: () => h(UsergroupAddOutlined),
      },
    },
  ],
})

export default router
